WIP ROX-33217: Instrument inode tracking on directory being created#449
Draft
JoukoVirtanen wants to merge 20 commits intomainfrom
Draft
WIP ROX-33217: Instrument inode tracking on directory being created#449JoukoVirtanen wants to merge 20 commits intomainfrom
JoukoVirtanen wants to merge 20 commits intomainfrom
Conversation
JoukoVirtanen
commented
Mar 30, 2026
| // x86_64 -> x86, aarch64 -> arm64 | ||
| let bpf_arch = match cargo_arch.as_str() { | ||
| "x86_64" => "x86", | ||
| "aarch64" => "arm64", |
Contributor
Author
There was a problem hiding this comment.
These changes are need because of
args.dir = (struct inode*)PT_REGS_PARM2_CORE(ctx);
args.dentry = (struct dentry*)PT_REGS_PARM3_CORE(ctx);
Which expects __TARGET_ARCH_x86 or __TARGET_ARCH_arm64 instead of __TARGET_ARCH_x86_64 or _TARGET_ARCH_aarch64. Currently both versions are used. One for PT_REGS_PARM2_CORE and one for fact-ebpf/src/bpf/vmlinux.h. Perhaps that file could be edited to use __TARGET_ARCH_x86 or __TARGET_ARCH_arm64. I don't know if that would cause other problems.
JoukoVirtanen
commented
Mar 30, 2026
| } | ||
|
|
||
| __always_inline static struct bound_path_t* _path_read(struct path* path, bound_path_buffer_t key, bool use_bpf_d_path) { | ||
| __always_inline static struct bound_path_t* _path_read(const struct path* path, bound_path_buffer_t key, bool use_bpf_d_path) { |
Contributor
Author
There was a problem hiding this comment.
I found that I needed to cast from const in one place, so I changed some function signatures to take in const to avoid that. I ended up using a cast from const in fact-ebpf/src/bpf/d_path.h anyways. I will likely change these back.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Directory creation events need to be handled correctly. When a directory is created in a tracked directory its inode should be added to a hash set in kernel space. In user space an entry needs to be added into a map with the inode as the key and file path as the value.
A downside of this approach is that it does not currently handle recursive cases, though I believe that this can be overcome.
I tried a few alternatives.
I started out trying to use a path_mkdir LSM hook, but as the design document suggested, it doesn't have the new inode. So, I tried tracepoints on the mkdir and mkdirat syscalls, which the design document suggested as an alternative. Neither of them worked. I also tried an LSM hook on
inode_mkdir, that didn't work either.Checklist
Automated testing
If any of these don't apply, please comment below.
Testing Performed
CI is sufficient.